#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000 + 5;
const int MOD = (int)1e9 + 7;
using LL = long long;

double k[maxn];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    k[i] = (b != 0 ? -1.0 * a / b : 2e17);
  }

  sort(k + 1, k + n + 1);
  int l = 1, r = 1;
  LL res = 0;
  for (int i = 1; i <= n; i++) {
    while (k[l] < k[i])
      l++;
    while (r <= n && !(k[i] < k[r]))
      r++;
    res = (res + (LL)(l - 1) * (n + 1 - r) % MOD) % MOD;
  }
  cout << res;
  return 0;
}